"""自定义过滤器，过滤点击排序html的class"""
import functools

from flask import current_app
from flask import g
from flask import session

from info import constants



def do_index_class(index):
    if index==0:
        return 'first'
    elif index == 1:
        return 'second'
    elif index == 2:
        return 'third'
    else:
        return ''


def user_logo_data(f):
    @functools.wraps(f)
    def warpper(*args,**kwargs):
        user_id = session.get('user_id', None)
        user = ''
        if user_id:
            try:
                from info.models import User
                user = User.query.get(user_id)
            except Exception as e:
                current_app.logger.error(e)
        g.user=user
        return f(*args,**kwargs)
    return warpper